#ifndef __MP3_H
#define __MP3_H

#include "flv.h"

FLVAPI enum {
	BITRATE_MPEG1,
	BITRATE_MPEG2,
	BITRATE_NUM
};
FLVAPI enum {
	SAMPLERATE_MPEG1,
	SAMPLERATE_MPEG2,
	SAMPLERATE_MPEG25,
	SAMPLERATE_NUM
};
#define MP3_FRAME_SYNC			0xFFE00000
#define MASK_VERSION			0x00180000
#define SHIFT_VERSION			19
#define MPEG_1				3
#define MPEG_2				2
#define MPEG_25				0
#define SHIFT_LAYER			17
#define LAYER_3				1
#define LAYER_2				2
#define LAYER_1				3
#define PROTECTION_BIT			0x00010000
#define MASK_BITRATE			0x0000f000
#define SHIFT_BITRATE		 	12
#define MASK_SAMPLERATE			0x00000C00
#define SHIFT_SAMPLERATE 		10
#define MASK_PADDING			0x00000200
#define MASK_CHANNEL                    0x000000C0
#define CHANNEL_STEREO       		0x00000000
#define CHANNEL_JOINT   	        0x00000040
#define CHANNEL_DUAL	                0x00000080
#define CHANNEL_MONO	                0x000000C0

struct FLVAPI Mp3Audio{
	CStream stream;
	int offset;
	int sr;
	int seekSamples;
	CBuffer *buf;
};
class FLVAPI CMp3Audio{
protected:
	CMp3Audio(){}
public:
	Mp3Audio m_mp3audio;
	static CMp3Audio* Create(const char* file,int offset);
};
#endif